from fastapi import APIRouter, Body
from pydantic import BaseModel
from app.engine.forecasting_engine import run_forecast

router = APIRouter()

class ForecastRequest(BaseModel):
    code: str
    days_to_predict: int = 30

@router.post("/")
async def start_forecast(request: ForecastRequest = Body(...)):
    """
    接收前端的预测请求，并调用预测引擎执行。
    """
    result = run_forecast(
        code=request.code,
        days_to_predict=request.days_to_predict
    )
    return result 